package com.xss.drawabletest;

import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.ScaleDrawable;
import android.graphics.drawable.TransitionDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.squareup.leakcanary.LeakCanary;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";
    ImageView imageView_level;
    TextView textView_transition;
    private TransitionDrawable transitionDrawable;
    ImageView imageView_scale;
    ImageView imageView_clip;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LeakCanary.install(getApplication());
        setContentView(R.layout.activity_main);
        DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        Log.d(TAG, "onCreate: 设备dpi："+displayMetrics.densityDpi);
        //imageview src+levle_list
        imageView_level=findViewById(R.id.image_level);
        imageView_level.setImageLevel(15);
        //textview transition
        textView_transition=findViewById(R.id.text_transition);
        transitionDrawable= (TransitionDrawable) textView_transition.getBackground();
        transitionDrawable.startTransition(3000);
        //scaledrawable
        imageView_scale=findViewById(R.id.image_scale);
        ScaleDrawable scaleDrawable= (ScaleDrawable) imageView_scale.getDrawable();
        imageView_scale.setImageLevel(1);
        //clipdrawable
        imageView_clip=findViewById(R.id.image_clip);
        ClipDrawable clipDrawable= (ClipDrawable) imageView_clip.getDrawable();
        imageView_clip.setImageLevel(9000);
    }

    public void click(View view) {
        imageView_level.setImageLevel(5);
        transitionDrawable.reverseTransition(3000);
        imageView_scale.setImageLevel(5000);
        imageView_clip.setImageLevel(4000);
    }
}
